#include <stdbool.h>
#include "timer_tick.h"

static volatile unsigned int tick;               //系统滴答计时

/*
 * @brief   增加系统节拍数(定时器中断中调用,1ms 1次)
 */
void systick_increase(unsigned int ms)
{
    tick += ms;
}

/*
 * @brief       获取系统滴答时钟值(通常单位是1ms)
 */
unsigned int get_tick(void)
{
    return tick;
}

/*
 * @brief       超时判断
 * @param[in]   start   - 起始时间
 * @param[in]   timeout - 超时时间(ms)
 */
bool is_timeout(unsigned int start, unsigned int timeout)
{
    return get_tick() - start > timeout;
}